package com.myCommon.util.resultUtil;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
      
      private Integer code;
      private String message;
      private Map<String, Object> data = new HashMap<>();
      
      
      public static R ok(){
            R r = new R();
            r.setCode(200);
            r.setMessage("返回成功");
            return r;
      }
      
      public static R ok(Integer code, String message) {
            R r = new R();
            r.setCode(code);
            r.setMessage(message);
            return r;
      }
      
      public static R fail() {
            R r = new R();
            r.setCode(500);
            r.setMessage("返回失败");
            return r;
      }
      
      public static R fail(Integer code, String message) {
            R r = new R();
            r.setCode(code);
            r.setMessage(message);
            return r;
      }
      
      public R data(String name, Object value) {
            this.data.put(name, value);
            return this;
      }
      
}
